# Maintainer: David Runge <dvzrv@archlinux.org>

_name=cytoolz
pkgname=python-cytoolz
pkgver=0.12.1
pkgrel=2
pkgdesc="Cython implementation of Toolz: High performance functional utilities"
arch=(loong64 x86_64)
url="https://github.com/pytoolz/cytoolz/"
license=(BSD)
depends=(cython python-toolz)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('84d627d4c894424f0267e65ab3eeee86a535b7f9e649051253702f17d4add7608d18496f453f174361a2a19d188127a056c66a9cbccaa83e1a305bbbf1d0f269')
b2sums=('86fff06fa2a8340889d5e54a598aafc7b2cf97c6d524d767b1f477f728b167c4cc2630b42bef0765e9a444745d3051e6c72a7589efb1a07098096847f2e0be63')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv test_dir/$_site_packages
}

package() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm -frv "$pkgdir/$_site_packages/$_name/tests"
}
